/**
 * @Title: ResultMsg.java
 * @Package com.ruiyi.carassistant.entity.common
 * @Description: TODO(用一句话描述该文件做什么)
 * @author A18ccms A18ccms_gmail_com
 * @date 2017年4月6日 下午1:44:20
 * @version V1.0
 */
package com.ruiyi.adrobot.beans.common;

import java.util.Map;

/**
 * @author tao.zeng
 * @ClassName: ResultMsg
 * @Description:
 * @date 2017年4月6日 下午1:44:20
 */
public class ResultMsg<T> {

    private Boolean success = false;

    private String error = "";

    private String errorCode = "";

    private T returnInfo = null;

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public T getReturnInfo() {
        return returnInfo;
    }

    public void setReturnInfo(T returnInfo) {
        this.returnInfo = returnInfo;
    }

    public static ResultMsg<Map<String, Object>> success() {
        ResultMsg<Map<String, Object>> success = new ResultMsg<>();
        success.success = true;
        return success;
    }

    public static <T> ResultMsg<T> success(T returnInfo) {
        ResultMsg<T> success = new ResultMsg<>();
        success.success = true;
        success.returnInfo = returnInfo;
        return success;
    }

    public static <T> ResultMsg<T> error(String errorMsg) {
        ResultMsg<T> error = new ResultMsg<>();
        error.success = false;
        error.error = errorMsg;
        return error;
    }

    public static <T> ResultMsg<T> error() {
        ResultMsg<T> error = new ResultMsg<>();
        error.success = false;
        error.error = "服务器异常";
        return error;
    }

    public static ResultMsg<Map<String, Object>> error(String errorMsg, String errorCode) {
        ResultMsg<Map<String, Object>> error = new ResultMsg<>();
        error.success = false;
        error.error = errorMsg;
        error.errorCode = errorCode;
        return error;
    }

}
